@include('backstage/public/_header')
    <!--結果集標題與導航組件 開始-->
    <div class="result_wrap">
        <!-- <div class="result_title">
            <h3>快捷操作</h3>
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href="#"><i class="fa fa-plus"></i>新增文章</a>
                <a href="#"><i class="fa fa-recycle"></i>批量刪除</a>
                <a href="#"><i class="fa fa-refresh"></i>更新排序</a>
            </div>
        </div> -->
    </div>
    <!--結果集標題與導航組件 結束-->
    <div class="result_wrap">
        <form id="form_data" method="post">
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <input type="hidden" name="id" value="{{$info->id}}">
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th  width="120"><i class="require" maxlength="20">*</i>帳號：</th>
                        <td>
                            <input type="text" name="user_name" value="{{$info->user_name}}">
                            <span><i class="fa fa-exclamation-circle yellow"></i>支持中文、字母、數字、“-”“_”的組合，4-20個字符</span>
                        </td>
                    </tr>
                    <tr>
                        <th>所屬用護組：</th>
                        <td class="role">
                            <select name="u_group_id" id="u_group_id">
                                <option value="">==請選擇==</option>
                                @foreach ($group as $v)
                                    <option value="{{$v->id}}" @if($info->u_group_id==$v->id) selected @endif>{{$v->role}}</option>
                                @endforeach
                            </select>
                            <span><i class="fa fa-exclamation-circle yellow"></i>管理員扮演的角色，所屬不同，權限也會不壹洋</span>
                        </td>
                    </tr>
                    <tr>
                        <th>QQ：</th>
                        <td>
                            <input type="text" name="qq" value="{{$info->qq}}">
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>真實姓名：</th>
                        <td>
                            <input type="text" name="real_name" value="{{ $info->real_name }}">
                            <span><i class="fa fa-exclamation-circle yellow"></i>務必填寫管理員真實姓名，方便管理</span>
                        </td>
                    </tr>
                    <tr>
                        <th>電話號碼：</th>
                        <td>
                            <input type="text" name="phone" value="{{ $info->phone }}">
                            <span><i class="fa fa-exclamation-circle yellow"></i>建議填寫手機號碼，方便聯系</span>
                        </td>
                    </tr>
                    
                    <tr>
                        <th></th>
                        <td>
                            <input type="button" value="提交" id="btnSub" onclick="onSubmit();">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
        <div class="tips">
            <h3>修改管理員說明</h3>
            <p>1、帶<i class="require">*</i>為必填項，不允許為空</p>
            <p>2、根據管理員id修改管理員admin表</p>
            <p>3、點擊提交 -&gt; 修改管理員，返回-&gt; 可以回到管理員列表</p>
        </div>
    </div>
    <script type="text/javascript">
    var vfTime = 2;
    var timer=null;
    function setTime(){
        vfTime --;
        if(vfTime<=0){
            vfTime = 0;
            clearInterval(timer);
        }
    }
    

    function onSubmit(){
        var user_name=$(":input[name='user_name']").val();
        var real_name=$(":input[name='real_name']").val();
        var u_group_id = $("#u_group_id").val();
        if (vfTime!=0 && timer!=null){
            layer.msg('操作過於頻繁', {icon: 7,anim: 6});
            // setTimeout(function(){$("#chiContent").focus();}, 1500);
            return false;
        }
        if (user_name==''){
            layer.msg('帳號不能為空', {icon: 5,anim: 6});
            setTimeout(function(){$(":input[name='user_name']").focus();}, 0);
            return false;
        }
        if (real_name=='') {
            layer.msg('真實姓名不能為空！', {icon: 5,anim: 6});
            setTimeout(function(){$(":input[name='real_name']").focus();}, 0);
            return false;
        }
        if (u_group_id=='' || u_group_id==0) {
            layer.msg('請選擇用護組權限！', {icon: 5,anim: 6});
            $('#u_group_id').click();
            return false;
        }
        var form = new FormData(document.getElementById("form_data"));
//             var req = new XMLHttpRequest();
//             req.open("post", "${pageContext.request.contextPath}/public/testupload", false);
//             req.send(form);
        $.ajax({
            url:"{{$doedit}}",
            type:"post",
            data:form,
            processData:false,
            contentType:false,
            dataType : "json",
            success:function(data){
                if(data.status==1){
                    layer.msg(data.message, {icon: 6});
                    setTimeout(function(){
                        window.location.href=data.jumpUrl;
                    },2000);
                }else if(data.status==-1){
                    layer.alert(data.message, {icon: 2,anim:6});
                }else{
                    layer.msg(data.message, {icon: 5});
                }
                clearInterval(timer);
                timer = setInterval(setTime, 1000, "1");
                
            },
            error:function(e){
                layer.msg(e, {icon: 5,anim: 6});
                clearInterval(timer);
                timer = setInterval(setTime, 1000, "1");
            }
        });
    }
    </script>
@include('backstage/public/_footer')